<div class="row">
    <div class="col-sm-12">
        <div class="box">
            <div class="box-header with-border">
                <h3 class="page-header"><i class="fa fa-edit"></i> <?php echo $site["ipaddr"];?> 配置修改</h3>
            </div>
            <div class="box-body">


            <div class="form-group col-sm-12">
                    <?php  echo '<label for="url"'._stringify_attributes(array('class' => 'col-sm-2 control-label')).'>宝塔管理地址</label>';?>
                    <div class="col-sm-8" shopid="<?php echo $site["id"]; ?>"> 
                        <span style="line-height:20px;" ondblclick="edit(this,'bturl')"><?php echo $site["bturl"]?$site["bturl"]:"双击设置";?></span>
                    </div>
               
            </div>

            <div class="form-group col-sm-12">
                    <?php  echo '<label for="url"'._stringify_attributes(array('class' => 'col-sm-2 control-label')).'>用户名</label>';?>
                    <div class="col-sm-8" shopid="<?php echo $site["id"]; ?>"> 
                        <span style="line-height:20px;" ondblclick="edit(this,'username')"><?php echo $site["username"]?$site["username"]:"双击设置";?></span>
                    </div>
               
            </div>

            <div class="form-group col-sm-12">
                    <?php  echo '<label for="url"'._stringify_attributes(array('class' => 'col-sm-2 control-label')).'>密码</label>';?>
                    <div class="col-sm-8" shopid="<?php echo $site["id"]; ?>"> 
                        <span style="line-height:20px;" ondblclick="edit(this,'pass')"><?php echo $site["pass"]?$site["pass"]:"双击设置";?></span>
                    </div>
               
            </div>

            <div class="form-group col-sm-12">
                    <?php  echo '<label for="url"'._stringify_attributes(array('class' => 'col-sm-2 control-label')).'>ROOT密码</label>';?>
                    <div class="col-sm-8" shopid="<?php echo $site["id"]; ?>"> 
                        <span style="line-height:20px;" ondblclick="edit(this,'rootpass')"><?php echo $site["rootpass"]?$site["rootpass"]:"双击设置";?></span>
                    </div>
                
            </div>
            
            </div>

        </div>
    </div>
</div>

<script>
    atedit=0;
    function edit(obj,attrName){
        if (atedit==1)
        return;
        else
        atedit=1;

        var oldHtml = obj.innerHTML;
        var newobj = document.createElement('input');
        newobj.name = attrName;
        newobj.type = "text";
        newobj.setAttribute("class","form-control input-sm");
        if($.trim(oldHtml)!="双击设置"){
            newobj.value = oldHtml;
        }

        var cid = $(obj).parent().attr("shopid");     
        obj.innerHTML = '';  
        obj.appendChild(newobj);
        newobj.focus(); 

        $(newobj).keydown(function (event) {
            if (event.keyCode == 13) {
                $(this).trigger("blur");
            }
        });

       
        eurl="/backend/server/ajaxedit";
      
        $(newobj).blur(function(){
            atedit=0;
            if(this.value==null || this.value==""){
                obj.innerHTML = oldHtml;
                return false;
            }
            obj.innerHTML = this.value?this.value:oldHtml;       
            if(oldHtml != this.value){
                $.ajax({
                    type:"post",
                    url:eurl,
                    dataType:"json",
                    data:{"attrName":attrName,"newHtml":this.value,"cid":cid},
                    error:function(){
                    },
                    success:function(){
                        layer.msg("更新成功");
                    },
                });
            }  

        })
    }


</script>
